<?php
/**
 * Created by PhpStorm.
 * User: jim
 * Date: 2016-12-24
 * Time: 21:39
 */

namespace App\Http\Controllers\chat;


use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Intervention\Image\Facades\Image;
use SimpleSoftwareIO\QrCode\Facades\QrCode;
class CodeController extends Controller
{
    public function code(Request $request)
    {
        $id=$request->input('id');

        $name=$request->input('name');
        $url="http://".$_SERVER['HTTP_HOST']."/home/user/register/".$id.'/';

            QrCode::format('png')->size(450)->generate($url,public_path('img/qrcode.png'));
            while(!file_exists('img/qrcode.png')){
                usleep(1);
            }
        Image::make('img/bgcode.jpg')->resize(1080, 1704)->insert('img/qrcode.png', 'bottom-right', 300, 400)->save('img/a3.jpg');
            unlink('img/qrcode.png');
        return view('code');

    }
}